
<html>
	<head>
		<title>
			
		</title>
	</head>
	
	<?php
	
	?>
	
	<body>
		<form method="post" action="">
			String <input type="text" name="str" />
			Search <input  "text" name="search" />
			Replace <input  type="text" name="replace" />
			
		     <input type="submit" name="submit"/>
		</form><h1>
		
		<?php
	if(isset($_POST['submit' ]))
	{
		function myLength($word)
		{
			$count =0;
			while(true)
			{
				if(!isset($word[$count]))
				return $count;
			
				$count++;
			}
			
		}
		
		
		function myReplacer($word,$search,$replace)
		{
			$count=0;
			
			$length = myLength($word);
			$length2 = myLength($search);

			for($i=0;$i<$length;$i++)
			{
				
				$tword="";
				for($k=$i;$k<($length);$k++)
				{
				  $tword.=$word[$k];
				  if($tword==$search)
				  {
				 	return $tword;
				  }
					
				}

			}
			
			return $word;
		}
		
		$string = $_POST['str'];
		$search = $_POST['search'];
		$replace = $_POST['replace'];
     
	    echo myReplacer($string, $search, $replace);

	}
		
		?>
	</h1>
		
	</body>
</html>